package single.single;

public class SingleObject {

    private static SingleObject instance;

    private SingleObject(){};

    public static SingleObject getInstance(){
        if(instance == null){
//            第一重校验
            synchronized (SingleObject.class){
//                加锁
                if (instance == null){
//                    第二重校验
                    instance = new SingleObject();
                }
            }
        }
        return instance;
    }

}
